﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <Color x:Key="AlternatingRowBackgroundColor">#e9e9e9</Color>
    <Color x:Key="ContentAreaColorLight">#FFC5CBF9</Color>
    <Color x:Key="ContentAreaColorDark">#FF7381F9</Color>
    <Color x:Key="ControlLightColor">White</Color>
    <Color x:Key="ControlMediumColor">#FF7381F9</Color>
    <Color x:Key="ControlDarkColor">#FF211AA9</Color>
    <Color x:Key="ControlPressedColor">#FF211AA9</Color>


    <ControlTemplate x:Key="RowTemplate" TargetType="{x:Type DataGridRow}">
        <Border x:Name="DGR_Border"
                BorderBrush="{TemplateBinding BorderBrush}"
                BorderThickness="{TemplateBinding BorderThickness}"
                SnapsToDevicePixels="True">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="White" Offset="0" />
                    <GradientStop Color="{Binding Background.Color, RelativeSource={RelativeSource TemplatedParent}, FallbackValue={StaticResource ControlLightColor}}" Offset="0" />
                </LinearGradientBrush>
            </Border.Background>
            <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                    <VisualState x:Name="Normal" />

                    <!--Provide a different appearance for every other row.-->
                    <VisualState x:Name="Normal_AlternatingRow">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border"
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource AlternatingRowBackgroundColor}" />
                            </ColorAnimationUsingKeyFrames>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border"
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{StaticResource AlternatingRowBackgroundColor}" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="Normal_Selected">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border"
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Cmdr.HighlightColor}" />
                            </ColorAnimationUsingKeyFrames>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" 
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Cmdr.HighlightColor}" />
                            </ColorAnimationUsingKeyFrames>
   
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="Unfocused_Selected">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" 
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Cmdr.HighlightColor}" />
                            </ColorAnimationUsingKeyFrames>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border"
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Cmdr.HighlightColor}" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="Normal_Editing">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border"
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Cmdr.HighlightColor}" />
                            </ColorAnimationUsingKeyFrames>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border"
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Cmdr.HighlightColor}" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>

                    <VisualState x:Name="Unfocused_Editing">
                        <Storyboard>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" 
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[0].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Cmdr.HighlightColor}" />
                            </ColorAnimationUsingKeyFrames>
                            <ColorAnimationUsingKeyFrames Storyboard.TargetName="DGR_Border" 
                                                          Storyboard.TargetProperty="(Panel.Background).(GradientBrush.GradientStops)[1].(GradientStop.Color)">
                                <EasingColorKeyFrame KeyTime="0" Value="{DynamicResource Cmdr.HighlightColor}" />
                            </ColorAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>

            <SelectiveScrollingGrid>
                <SelectiveScrollingGrid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" />
                    <ColumnDefinition Width="*" />
                </SelectiveScrollingGrid.ColumnDefinitions>
                <SelectiveScrollingGrid.RowDefinitions>
                    <RowDefinition Height="*" />
                    <RowDefinition Height="Auto" />
                </SelectiveScrollingGrid.RowDefinitions>

                <DataGridCellsPresenter Grid.Column="1" Grid.Row="0"
                                        ItemsPanel="{TemplateBinding ItemsPanel}"
                                        SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                <DataGridDetailsPresenter Grid.Column="1" Grid.Row="1"
                                          Visibility="{TemplateBinding DetailsVisibility}"
                                          SelectiveScrollingGrid.SelectiveScrollingOrientation="{Binding AreRowDetailsFrozen, ConverterParameter={x:Static SelectiveScrollingOrientation.Vertical}, Converter={x:Static DataGrid.RowDetailsScrollingConverter}, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
            </SelectiveScrollingGrid>
        </Border>
    </ControlTemplate>

</ResourceDictionary>